class_name HoldGunIntelligence
extends BaseHoldItem

@onready var muzzle: Marker2D = $Muzzle


func shoot():
	var player = holder as Player
	var config = item_data.item_config as ItemGunBaseConfig
	
	var bullet_inst = (ResourceManager.get_resource("bullet_intelligence") as PackedScene).instantiate() as BulletIntelligence
	player.level.bullets_parent.add_child(bullet_inst)
	bullet_inst.global_position = muzzle.global_position
	bullet_inst.global_rotation = player.gun_hand.global_rotation
	bullet_inst.sender = player
	bullet_inst.attack = config.attack + player.player_data.get_attack()
	bullet_inst.critical_rate = config.critical_rate
	bullet_inst.critical_bonus = config.critical_bonus
	bullet_inst.knockback = config.knockback
	bullet_inst.shoot_dir = Vector2.from_angle(player.gun_hand.global_rotation)
	bullet_inst.velocity = bullet_inst.shoot_dir * bullet_inst.speed
	bullet_inst.hit_cam_shake_intensity = config.attack_cam_shake_intensity
	bullet_inst.hit_cam_shake_duration = config.attack_cam_shake_duration
	
	AudioManager.play_sound("sfx_intelligence_gun_shoot")
